# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=itstool
pkgver=2.0.6
pkgrel=2
pkgdesc="XML to PO and back again"
arch=('i686' 'x86_64')
url="http://itstool.org/"
license=("GPL3")
depends=("python" "libxml2" "libxml2-python")
source=(http://files.itstool.org/itstool/${pkgname}-${pkgver}.tar.bz2
        fix-segfault.patch
        itstool-2.0.5-fix-crash-wrong-encoding.patch)
sha256sums=('6233cc22726a9a5a83664bf67d1af79549a298c23185d926c3677afa917b92a9'
            'ccdf85ae9bdfd0259728a79b6b9806d8b9bcb27ed1f974ac49c551587cb4e6c6'
            'cb57e3694ab3d7c62b063629b2e9edc6327260c0797d0f33c8dc97fe37c40ebb')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/itstool-2.0.5-fix-crash-wrong-encoding.patch
  patch -p1 -i ${srcdir}/fix-segfault.patch

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${CHOST}"
  cd "${srcdir}/build-${CHOST}"
    PYTHON=/usr/bin/python \
    ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST}
    make
}

check() {
  cd build-${CHOST}
  make -k check
}

package() {
  cd "${srcdir}/build-${CHOST}"
  make DESTDIR="${pkgdir}" install
}
